//
//  LHRecommedCityCollectionViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-14.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommedCityCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommedCityCollectionViewCell ()

@property (nonatomic, retain) UIImageView *recommedCity;
@property (nonatomic, retain) UILabel *cityName;

@end

@implementation LHRecommedCityCollectionViewCell

/**
 *  初始化 创建控件
 */
- (void)dealloc
{
    [_recommedCity release];
    [_cityName release];
    [_recommendCityModel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        // 相框创建
        self.recommedCity = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_recommedCity];
        self.recommedCity.layer.cornerRadius = 5;
        self.recommedCity.clipsToBounds = YES;
        
        _recommedCity.backgroundColor = [UIColor colorWithRed:0.416 green:0.572 blue:0.075 alpha:1.000];
        
        [_recommedCity release];
        
        // 城市标签创建
        self.cityName = [[UILabel alloc] init];
        
        [_recommedCity addSubview:_cityName];
        
        [_cityName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
        
        [_cityName setTextColor:[UIColor whiteColor]];
        
        [_cityName setShadowColor:[UIColor blackColor]];
        
        [_cityName setShadowOffset:CGSizeMake(1, 0)];
        
        [_cityName release];
        

        
    }
    
    
    return self;
}

/**
 *  布局信息方法
 */

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _recommedCity.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width );
    
    _cityName.frame = CGRectMake(10, _recommedCity.frame.size.height - 30, 70, 30);
    
}

/**
 *  重写setter方法
 */

- (void)setRecommendCityModel:(LHRecommendCityModel *)recommendCityModel
{
    if (_recommendCityModel != recommendCityModel) {
        
        [_recommendCityModel release];
        
        _recommendCityModel = [recommendCityModel retain];
        
    }

    _cityName.text = recommendCityModel.name;
    [_cityName setTextColor:[UIColor whiteColor]];
    
    [_recommedCity sd_setImageWithURL:[NSURL URLWithString:recommendCityModel.cover] placeholderImage:[UIImage imageNamed:@"word4"]];
    

    
    
    
    
}






@end
